define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'level/index' + location.search,
                    add_url: 'level/add',
                    edit_url: 'level/edit',
                    del_url: 'level/del',
                    multi_url: 'level/multi',
                    import_url: 'level/import',
                    table: 'level',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'vl_id',
                sortName: 'vl_id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'vl_id', title: __('Vl_id'),visible:false},
                        {field: 'vip_name', title: __('Vip_name'), operate: 'LIKE'},
                        {field: 'vip_rule', title: __('Vip_rule'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'vip_icon', title: __('Vip_icon'), operate: 'LIKE', formatter: Table.api.formatter.image},
                        {field: 'basic_price', title: '基础价格(元)', operate:'BETWEEN'},
                        {field: 'store_money', title: __('Store_money'), operate:'BETWEEN'},
                        {field: 'store_false_money', title: __('Store_false_money'), operate:'BETWEEN'},
                        {field: 'match_money', title: __('Match_money'), operate:'BETWEEN'},
                        {field: 'captain_rebate', title: __('Captain_rebate')+'(%)', operate:'BETWEEN'},
                        {field: 'store_rebate', title: __('Store_rebate')+'(%)', operate:'BETWEEN'},
                        {field: 'proxy_rebate', title: '代理返点(%)', operate:'BETWEEN'},
                        {field: 'platform_rebate', title: '平台费率(%)', operate:'BETWEEN'},
                        {field: 'all_count', title: __('All_count')},
                        {field: 'assistant_price', title: '助理价格(元)'},
                        {field: 'time_unit', title: '助教时间(分钟)'},
                        {field: 'remarks', title: __('Remarks'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'delete', title: __('Delete'), searchList: {"0":__('Delete 0'),"1":__('Delete 1')}, formatter: Table.api.formatter.normal},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
